package com.atguigu.service.eud_teacher.edu_subject.controller;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import com.atguigu.commonutils.R;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.atguigu.service.eud_teacher.edu_subject.entity.CrmBannerEntity;
import com.atguigu.service.eud_teacher.edu_subject.service.CrmBannerService;



/**
 * 首页banner表
 *
 * @author wuyao
 * @email 13918471632@163.com
 * @date 2021-03-23 12:12:26
 */
@RestController
@RequestMapping("/edu_banner/crmadminbanner")
@CrossOrigin
@Api(tags = "幻灯篇后台管理接口API")
public class CrmAdminBannerController {

    @Autowired
    private CrmBannerService crmBannerService;

    @ApiOperation(value="分页查询所有幻灯片信息",notes = "records为列表集合数据，limit为显示几条信息，current当前页，total为总条数")
    @GetMapping("/getAllBannerByPage/{current}/{limit}")
    public R getAllBannerByPage(@PathVariable Long current,
                                @PathVariable Long limit){
        Page<CrmBannerEntity> bannerPage = new Page<>(current,limit);
        IPage<CrmBannerEntity> pages = crmBannerService.page(bannerPage, null);
        List<CrmBannerEntity> records = pages.getRecords();
        long total = pages.getTotal();
        return R.ok().data("items",records).data("total",total);
    }
}
